
let nativemodule = weex.requireModule("acmedEventModule");
class WeexNativeModule{
    static toast(msg){
        nativemodule.callNative("toast",msg,null);
    }
    static finish(){
        nativemodule.callNative("finish",null,null);
    }
    static alert(msg){
        // nativemodule.callNative("Alert",msg,null);
    }
    static log(key,value){
        let param = {
            key:key,
            msg:value
        };
        nativemodule.callNative("Log",param,null);
    }
    static getParam(jscallback){
        nativemodule.callNative("getParam",null,jscallback);
    }
    static saveData(data,jscallback){
        nativemodule.callNative("saveData",data,jscallback);
    }
    static refreshNativePage(){
        nativemodule.callNative("refreshNativePage",null,null);
    }
    static selectDateTime(defaulttime,ishowyear,isshowmonth,isshowday
        ,isshowhour,isshowminute,isshowsencond,islimittime,
                          starttime,endtime,jscallback){
        let param = {};
        param.defaulttime = defaulttime;
        param.isshowyear = ishowyear;
        param.isshowmonth = isshowmonth;
        param.isshowday = isshowday;
        param.isshowhour = isshowhour;
        param.isshowminute = isshowminute;
        param.isshowsencond = isshowsencond;
        param.islimittime = islimittime;
        param.starttime = starttime;
        param.endtime = endtime;
        nativemodule.callNative("selectDateTime",param,jscallback);
    }

    static selectOption(defaultitem,param,jscallback){
        let data = {};
        data.defaultkey = defaultitem;
        data.data = param;
        nativemodule.callNative("selectOption",data,jscallback);
    }

    static post(baseurl,url,json,jscallback){
        let param={};
        param.baseUrl = baseurl;
        param.url = url;
        param.data=json;
        nativemodule.callNative("posturl",param,function (res) {
            let resultType = res.resultType;
            let result = res.result;
            if("onSuccess" == resultType){
                jscallback.onSuccess(result);
            }else {
                jscallback.onError(result);
            }
        });
    }

    static put(baseurl,url,json,jscallback){
        let param={};
        param.baseUrl = baseurl;
        param.url = url;
        param.data=json;
        nativemodule.callNative("puturl",param,function (res) {
            let resultType = res.resultType;
            let result = res.result;
            if("onSuccess" == resultType){
                jscallback.onSuccess(result);
            }else {
                jscallback.onError(result);
            }
        });
    }

    static get(baseurl,url,jscallback){
        let param={};
        param.baseUrl = baseurl;
        param.url = url;
        nativemodule.callNative("geturl",param,function (res) {
            let resultType = res.resultType;
            let result = res.result;
            if("onSuccess" == resultType){
                jscallback.onSuccess(result);
            }else {
                jscallback.onError(result);
            }
        });
    }

    static getLoginUser(jscallback){
        nativemodule.callNative("getLoginUser",'',jscallback)
    }
    // 签名
    static signName(jscallback) {
        nativemodule.callNative("signName",'',jscallback)
    }

    static showProgressDialog(msg) {
        let param = {}
        param.msg = msg
        nativemodule.callNative("showProgressDialg",param,null)
    }

    static dimissProgressDialog(jscallback) {
        nativemodule.callNative("dimissProgressDialog",'',jscallback)
    }
    static getBuildType(jscallback){
        nativemodule.callNative("getBuildType",'',jscallback)
    }
    static mountedfinish(){
        nativemodule.callNative("mountedfinish",null,null)
    }
}

export default WeexNativeModule;